/*
 * ONGestionaGastos.java
 *
 * Created on 30 de abril de 2008, 13:01
 */

package ongclientejava;
import javax.swing.JOptionPane;
import org.jdesktop.application.Action;



/**
 *
 * @author  Cristo Manuel
 */
public class ONGestionaGastos extends javax.swing.JDialog {
    
   private  String descrip;
   private String cant;
   private int result;
    
    /** Creates new form ONGestionaGastos */
    public ONGestionaGastos(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
       
   
        //getRootPane().setDefaultButton(jBTarCancelarGasto);
    }
    
    @Action public void closeGastos() {
        setVisible(false);
        result=0;
    }
    public void LimpiarDatos(){
        jTFTarDescripcionGasto.setText("");
        jTFTarCantidadGasto.setText("");
    }
    
    public String getDescripcion(){
        return descrip;
    }
    public String getCantidad(){
            return cant;
   }
    public int getResultado(){
        return result;
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTFTarDescripcionGasto = new javax.swing.JTextField();
        jTFTarCantidadGasto = new javax.swing.JTextField();
        jLTarDescripcionGasto = new javax.swing.JLabel();
        jLTarCantidadGasto = new javax.swing.JLabel();
        jBTarAceptarGasto = new javax.swing.JButton();
        jBTarCancelarGasto = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(ongclientejava.ONGestionaApp.class).getContext().getResourceMap(ONGestionaGastos.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N

        jTFTarDescripcionGasto.setName("jTFTarDescripcionGasto"); // NOI18N
        jTFTarDescripcionGasto.setPreferredSize(new java.awt.Dimension(200, 20));

        jTFTarCantidadGasto.setMinimumSize(new java.awt.Dimension(200, 20));
        jTFTarCantidadGasto.setName("jTFTarCantidadGasto"); // NOI18N

        jLTarDescripcionGasto.setText(resourceMap.getString("jLTarDescripcionGasto.text")); // NOI18N
        jLTarDescripcionGasto.setName("jLTarDescripcionGasto"); // NOI18N

        jLTarCantidadGasto.setText(resourceMap.getString("jLTarCantidadGasto.text")); // NOI18N
        jLTarCantidadGasto.setName("jLTarCantidadGasto"); // NOI18N

        jBTarAceptarGasto.setText(resourceMap.getString("jBTarAceptarGasto.text")); // NOI18N
        jBTarAceptarGasto.setName("jBTarAceptarGasto"); // NOI18N
        jBTarAceptarGasto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBTarAceptarGastoActionPerformed(evt);
            }
        });

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(ongclientejava.ONGestionaApp.class).getContext().getActionMap(ONGestionaGastos.class, this);
        jBTarCancelarGasto.setAction(actionMap.get("closeGastos")); // NOI18N
        jBTarCancelarGasto.setText(resourceMap.getString("jBTarCancelarGasto.text")); // NOI18N
        jBTarCancelarGasto.setName("jBTarCancelarGasto"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLTarDescripcionGasto)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jBTarAceptarGasto)
                        .addGap(18, 18, 18)
                        .addComponent(jBTarCancelarGasto)
                        .addGap(115, 115, 115))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jTFTarCantidadGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(jLTarCantidadGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(129, 129, 129))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jTFTarDescripcionGasto, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
                            .addContainerGap(22, javax.swing.GroupLayout.PREFERRED_SIZE)))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 185, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(37, 37, 37)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLTarDescripcionGasto)
                    .addComponent(jTFTarDescripcionGasto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFTarCantidadGasto, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLTarCantidadGasto))
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBTarAceptarGasto)
                    .addComponent(jBTarCancelarGasto))
                .addContainerGap(43, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBTarAceptarGastoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBTarAceptarGastoActionPerformed
        // TODO add your handling code here:
       descrip=jTFTarDescripcionGasto.getText();
       cant=jTFTarCantidadGasto.getText();
       if(cant.isEmpty())
           cant="0";
        result=1;
        setVisible(false);
    }//GEN-LAST:event_jBTarAceptarGastoActionPerformed
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                ONGestionaGastos dialog = new ONGestionaGastos(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBTarAceptarGasto;
    private javax.swing.JButton jBTarCancelarGasto;
    private javax.swing.JLabel jLTarCantidadGasto;
    private javax.swing.JLabel jLTarDescripcionGasto;
    private javax.swing.JTextField jTFTarCantidadGasto;
    private javax.swing.JTextField jTFTarDescripcionGasto;
    // End of variables declaration//GEN-END:variables
    
}
